home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 1 / Precision Software Applications Silver Collection Volume One (PSM) (1993).iso / tutor / cptuts22.arj / STRUCTUR.CPP < prev    next >
C/C++ Source or Header  |  1992-01-20  |  665b  |  37 lines

  1.                                  // Chapter 2 - Program 2
  2. #include <iostream.h>
  3.  
  4. struct animal {
  5.    int weight;
  6.    int feet;
  7. };
  8.  
  9. main()
  10. {
  11. animal dog1, dog2, chicken;
  12. animal cat1;
  13. struct animal cat2;
  14.  
  15.    dog1.weight = 15;
  16.    dog2.weight = 37;
  17.    chicken.weight = 3;
  18.  
  19.    dog1.feet = 4;
  20.    dog2.feet = 4;
  21.    chicken.feet = 2;
  22.  
  23.    cout << "The weight of dog1 is " << dog1.weight << "\n";
  24.    cout << "The weight of dog2 is " << dog2.weight << "\n";
  25.    cout << "The weight of chicken is " << chicken.weight << "\n";
  26. }
  27.  
  28.  
  29.  
  30.  
  31. // Result of execution
  32. //
  33. // The weight of dog1 is 15
  34. // The weight of dog2 is 37
  35. // The weight of chicken is 3
  36.  
  37.